// import com.alibaba.druid.sql.ast.SQLExpr_ptr;
// import com.alibaba.druid.sql.ast.expr.SQLIntegerExpr;
// import com.alibaba.druid.sql.dialect.sqlserver.visitor.SQLServerASTVisitor;

#include "SQLServerTop.h"
#include "../../../ast/expr/SQLIntegerExpr.h"
#include "../visitor/SQLServerASTVisitor.h"

SQLServerTop::SQLServerTop()
{
}

SQLServerTop::SQLServerTop(SQLExpr_ptr expr)
{
  this->setExpr(expr);
}

SQLExpr_ptr SQLServerTop::getExpr()
{
  return expr;
}

void SQLServerTop::setExpr(SQLExpr_ptr expr)
{
  if (expr != nullptr)
  {
    expr->setParent(SharedObject(SQLServerTop));
  }
  this->expr = expr;
}

void SQLServerTop::setExpr(int expr)
{
  this->setExpr(SQLIntegerExpr_ptr(new SQLIntegerExpr(expr)));
}

BOOL_ptr SQLServerTop::isPercent()
{
  return percent;
}

void SQLServerTop::setPercent(BOOL_ptr percent)
{
  this->percent = percent;
}

BOOL_ptr SQLServerTop::isWithTies()
{
  return withTies;
}

void SQLServerTop::setWithTies(BOOL_ptr withTies)
{
  this->withTies = withTies;
}

// @Override
void SQLServerTop::accept0(SQLServerASTVisitor_ptr visitor)
{
  visitor->visit(SharedObject(SQLServerTop));
  visitor->endVisit(SharedObject(SQLServerTop));
}

SQLObject_ptr SQLServerTop::clone()
{
  SQLObject_ptr clone_tmp = std::shared_ptr<SQLServerTop>(new SQLServerTop());
  std::shared_ptr<SQLServerTop> x = std::dynamic_pointer_cast<SQLServerTop>(clone_tmp);
  // SQLServerTop x = new SQLServerTop();
  if (expr != nullptr)
  {
    x->setExpr(std::dynamic_pointer_cast<SQLExpr>(expr->clone()));
  }
  x->percent = percent;
  x->withTies = withTies;
  return x;
}
